﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CommonFramework.Web;
using Xinkui.Common.Enum;
using Xinkui.Common.FileAction;

namespace Back.Xinkui.WebModel
{
    public class AdvertAspxBase : PageAspxBase
    {
        /// <summary>
        /// 广告位类型
        /// </summary>
        /// <param name="ob"></param>
        /// <returns></returns>
        protected string SpaceTypeString(object ob)
        {
            string re = "";
            int type = Convert.ToInt16(ob);
            switch (type)
            {
                case 1: re = "常规广告"; break;
                case 2: re = "关键词广告"; break;
            }
            return re;
        }
        /// <summary>
        /// 广告位内容类型
        /// </summary>
        /// <param name="ob"></param>
        /// <returns></returns>
        protected string SourceTypeString(object ob)
        {
            string re = "";
            int type = Convert.ToInt16(ob);
            switch (type)
            {
                case 1: re = "文字广告"; break;
                case 2: re = "图片广告"; break;
                case 3: re = "Flash广告"; break;
                case 4: re = "文字滚动广告"; break;
                case 5: re = "图片滚动广告"; break;
            }
            return re;
        }
        /// <summary>
        /// 广告状态
        /// </summary>
        /// <param name="ob"></param>
        /// <returns></returns>
        protected string AdvertStatusString(object ob)
        {
            string re = "";
            int type = Convert.ToInt16(ob);
            switch (type)
            {
                case 0: re = "未启用"; break;
                case 2: re = "启用"; break;
                case 3: re = "已生效"; break;
                case 5: re = "即将到期"; break;
                case -1: re = "到期"; break;
            }
            return re;
        }
        protected string IsDeleteString(object ob)
        {
            string re = "";
            int type = Convert.ToInt16(ob);
            switch (type)
            {
                case 0: re = "正常"; break;
                case 1: re = "已删除"; break;
            }
            return re;
        }

        protected string DropAdvertStatusHtml(string id, string select)
        {
            string re = @"<select name='" + id + @"' id='" + id + @"'>";
            re += @"<option value='-8' selected='selected'>--请选择--</option>";
            re += @"<option value='0'>未启用</option>";
            re += @"<option value='2'>启用</option>";
            re += @"<option value='3'>已生效</option>";
            re += @"<option value='5'>即将到期</option>";
            re += @"<option value='-1'>到期</option>";
            re += @"</select>";
            re = SelectDrop(re, select);
            return re;
        }

        protected string DropChangeStatusHtml(string id, string select)
        {
            string re = @"<select name='" + id + @"' id='" + id + @"'>";
            re += @"<option value='-8' selected='selected'>--请选择--</option>";
            re += @"<option value='0'>未启用</option>";
            re += @"<option value='2'>启用</option>";
            re += @"</select>";
            re = SelectDrop(re, select);
            return re;
        }

        protected string DropSpaceTypeHtml(string id, string select)
        {
            string re = @"<select name='" + id + @"' id='" + id + @"'>";
            re += @"<option value='-8' selected='selected'>--请选择--</option>";
            re += @"<option value='1'>常规广告</option>";
            re += @"<option value='2'>关键词广告</option>";
            re += @"</select>";
            re = SelectDrop(re, select);
            return re;
        }

        protected string DropSourceTypeHtml(string id, string select)
        {
            string re = @"<select name='" + id + @"' id='" + id + @"'>";
            re += @"<option value='-8' selected='selected'>--请选择--</option>";
            re += @"<option value='1'>文字广告</option>";
            re += @"<option value='2'>图片广告</option>";
            re += @"<option value='3'>Flash广告</option>";
            re += @"<option value='4'>文字滚动广告</option>";
            re += @"<option value='5'>图片滚动广告</option>";
            re += @"</select>";
            re = SelectDrop(re, select);
            return re;
        }

        protected string DropSizeTypeHtml(string id, string select)
        {
            string re = @"<select name='" + id + @"' id='" + id + @"'>";
            re += @"<option value='-8' selected='selected'>--请选择--</option>";
            re += @"<option value='0'>一般尺寸</option>";
            re += @"<option value='1'>宽屏广告</option>";
            re += @"</select>";
            re = SelectDrop(re, select);
            return re;
        }
        private string SelectDrop(string html, string select)
        {
            if (!string.IsNullOrEmpty(select))
            {
                html = html.Replace("selected='selected'", "");
                if (html.IndexOf("option value='" + select + "'") > 0)
                    html = html.Insert(html.IndexOf("option value='" + select + "'") + "option value=''".Length + select.Length, " selected='selected'");
            }
            return html;
        }
    }
}
